@(repository: gitbucket.core.service.RepositoryService.RepositoryInfo,
  protectedBranchList: Seq[String],
  info: Option[Any])(implicit context: gitbucket.core.controller.Context)
@import gitbucket.core.view.helpers
@gitbucket.core.html.main("Branches", Some(repository)){
  @gitbucket.core.html.menu("settings", repository){
    @gitbucket.core.settings.html.menu("branches", repository){
      @if(repository.branchList.isEmpty){
        <div class="well">
          <center>
            <p><i class="octicon octicon-git-branch" style="font-size:300%"></i></p>
            <p>You don’t have any branches</p>
            <p>Before you can edit branch settings, you need to add a branch.</p>
          </center>
        </div>
      } else {
        @gitbucket.core.helper.html.information(info)
        <div class="panel panel-default">
          <div class="panel-heading strong">Default branch</div>
          <div class="panel-body">
            <p>The default branch is considered the “base” branch in your repository, against which all pull requests and code commits are automatically made (unless you specify a different branch).</p>
            <form id="form" method="post" action="@helpers.url(repository)/settings/update_default_branch" validate="true" class="form-inline">
              <span class="error" id="error-defaultBranch"></span>
              <select name="defaultBranch" id="defaultBranch" class="form-control" aria-label="Default branch">
                @repository.branchList.map { branch =>
                  <option @if(branch==repository.repository.defaultBranch){ selected}>@branch</option>
                }
              </select>
              <input type="submit" class="btn btn-default" value="Update" />
            </form>
          </div>
        </div>

        <div class="panel panel-default">
          <div class="panel-heading strong">Protected branches</div>
          <div class="panel-body">
            <p>Protect branches to disable force pushing, prevent branches from being deleted, and optionally, require status checks before merging.
              <form class="form-inline">
                <select name="protectBranch" id="protectBranch" onchange="location=$(this).val()" class="form-control" aria-label="Protect branch">
                  <option>Choose a branch...</option>
                  @repository.branchList.map { branch =>
                    <option value="@helpers.url(repository)/settings/branches/@helpers.urlEncode(branch)">@branch</option>
                  }
                </select>
                <span class="error" id="error-protectBranch"></span>
              </form>
            </p>

            <table class="table table-hover branches">
              @protectedBranchList.map { branch =>
                <tr>
                  <td>
                    <span class="branch-name">@branch</span>
                    <a href="@helpers.url(repository)/settings/branches/@helpers.urlEncode(branch)" class="btn btn-sm btn-default pull-right">Edit</a>
                  </td>
                </tr>
              }
            </table>
          </div>

        </div>
      }
    }
  }
}
